package com.kayden.blog.common.utils;

import com.kayden.blog.common.pojo.dataobject.BlogInfo;
import com.kayden.blog.common.pojo.dataobject.UserInfo;
import com.kayden.blog.common.pojo.request.UpdateBlogRequest;
import com.kayden.blog.common.pojo.response.BlogInfoResponse;
import com.kayden.blog.common.pojo.response.UserInfoResponse;
import org.springframework.beans.BeanUtils;

public class BeanTransUtils {

    public static BlogInfoResponse trans(BlogInfo blogInfo){
        if (blogInfo == null){
            //TODO
            return null;
        }
        BlogInfoResponse response = new BlogInfoResponse();
        BeanUtils.copyProperties(blogInfo,response);
        return response;
    }


    public static UserInfoResponse trans(UserInfo userInfo){
        if(userInfo == null){
            //TODO
            return null;
        }
        UserInfoResponse userInfoResponse = new UserInfoResponse();
        BeanUtils.copyProperties(userInfo,userInfoResponse);
        return userInfoResponse;
    }

    public static  BlogInfo trans(UpdateBlogRequest request){
        if (request == null){
            return  null;
        }
        BlogInfo blogInfo = new BlogInfo();
        BeanUtils.copyProperties(request,blogInfo);
        return blogInfo;
    }

}
